#! /bin/awk -f
# Author : Raman Rawat
#  awk -F- uuid.awk
#convert 
#			12ddfdc0-dedb-11d3-b844-0008c73f25e8
# to
#			{ 0x12ddfdc0, 0xdedb, 0x11d3, { 0xb8, 0x44, 0x00, 0x08, 0xc7, 0x3f, 0x25, 0xe8} };
# Sample Usage
#		uuidVal=`uuidgen` # Store it since it is needed later also
#		uuidStruct=`echo $uuidVal | awk -F- -f Uuid.awk`
# awk '/public/,/0/ { print $0}' CATISpecObjectDoc.txt  > CATISpecObject.h Split everything between public and 0

{

if( NF < 5) {
print "Minimum five fields expected. Found[" 
print NF
print "]"
}

strNull=0x
#1. add ox to first three
uuid="{ 0x"$1", 0x"$2", 0x"$3", { "
#print $uuid

#Make one string out of last two fields
strLast=$4$5

#add ox to every two characters
nLength=length(strLast) -1
for( i = 1; i <=nLength  ; i+=2) {
	uuid=uuid " 0x"substr(strLast, i, 2)
	
	# add comma except for last
	if( i != nLength ){
		uuid=uuid","
	}
}
# closing brackets
uuid=uuid " } }"
print uuid
}
